<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName" :fill="color" />
  </svg>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
const props = defineProps({
  name: { type: String, default: '' },
  color: { type: String, default: '' }
})

const iconName = computed(() => `#icon-${props.name}`)
const svgClass = computed(() => {
  if (props.name) {
    return `yh-icon ${props.name}`
  }
  return 'yh-icon'
})
</script>

<style lang="scss" scoped>
.yh-icon {
  width: 1.2em;
  height: 1.2em;
  position: relative;
  fill: currentColor;
  vertical-align: -2px;
}
</style>
